package main

import (
	"database/sql"
	_ "github.com/go-sql-driver/mysql"
	"fmt"
)

var(
	id int
	name string
	age int
)
func main(){
	db,err := sql.Open("mysql","vagrant:vagrant@tcp(127.0.0.1:3306)/test?charset=utf8")
	if err != nil {
		panic(err)
		return
	}
	defer db.Close()

	// 查一条
	select_sql := "select id,name,age from user"

	row := db.QueryRow(select_sql)

	if err = row.Scan(&id,&name,&age);err !=nil{
		fmt.Println("没有取到")
		return
	}
	fmt.Println(id,name,age)


}
